#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<stdlib.h>
#include<pthread.h>
#include<time.h>
#include<sys/types.h>
#include <unistd.h>
#include <sys/syscall.h>

#include<stdatomic.h>


// 线程传递参数
#define LOOP 100
#define THREAD 4000

static atomic_int_fast64_t x = 0;

void *inc(void *argc){
    for(int i=0; i<LOOP; i++){
        x++;
    }
}



int main(){
    pthread_t tid[THREAD];
    int ret;


    for(int i=0; i<THREAD; i++){
        ret = pthread_create(&(tid[i]), NULL, inc, NULL);
        if(ret != 0){
            printf("thread create error\n");
            exit(1);
        }
    }
    for(int i=0; i<THREAD; i++){
        pthread_join(tid[i], NULL);
    }

    printf("x = %ld\n", x);
    return 0;
}





